home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 2003 September / PC Answers September 2003.iso / Software / freeware / pixeltoolbox / Setup.exe / Main / PixelToolbox.exe / PixelToolbox.dxr / Scripts_35_8 bit gradient tools.ls < prev    next >
Encoding:
Text File  |  2002-06-08  |  15.3 KB  |  298 lines

  1. global gSize, gCast, gVariable, gFirstColor, gSecondColor, myCurrentImage, myCurrentPreview
  2.  
  3. on toolGradientH
  4.   member("state1 - " & gSize, gCast).image = member(gSize & "x" & gSize, gCast).image
  5.   startX = (the mouseH - sprite(1).left) * 2 / gVariable / 2
  6.   startY = (the mouseV - sprite(1).top) * 2 / gVariable / 2
  7.   myShape = rect(0, 0, 0, 0)
  8.   myStartImage = duplicate(member(gSize & "x" & gSize, gCast).image)
  9.   myCurrentImage = duplicate(member(gSize & "x" & gSize, gCast).image)
  10.   myCurrentPreview = duplicate(member("preview", gCast).image)
  11.   repeat while the mouseDown
  12.     myCurrentImage.copyPixels(myStartImage, myStartImage.rect, myStartImage.rect)
  13.     if (((the mouseV - sprite(1).top) * 2 / gVariable / 2) < startY) and (((the mouseH - sprite(1).left) * 2 / gVariable / 2) < startX) then
  14.       myShape = rect((the mouseH - sprite(1).left) * 2 / gVariable / 2, (the mouseV - sprite(1).top) * 2 / gVariable / 2, startX + 1, startY + 1)
  15.     else
  16.       if (((the mouseV - sprite(1).top) * 2 / gVariable / 2) < startY) and (((the mouseH - sprite(1).left) * 2 / gVariable / 2) >= startX) then
  17.         myShape = rect(startX, (the mouseV - sprite(1).top) * 2 / gVariable / 2, ((the mouseH - sprite(1).left) * 2 / gVariable / 2) + 1, startY + 1)
  18.       else
  19.         if (((the mouseV - sprite(1).top) * 2 / gVariable / 2) >= startY) and (((the mouseH - sprite(1).left) * 2 / gVariable / 2) < startX) then
  20.           myShape = rect((the mouseH - sprite(1).left) * 2 / gVariable / 2, startY, startX + 1, ((the mouseV - sprite(1).top) * 2 / gVariable / 2) + 1)
  21.         else
  22.           if ((the mouseV - sprite(1).top) * 2 / gVariable / 2) = startY then
  23.             myShape = rect(startX, (the mouseV - sprite(1).top) * 2 / gVariable / 2, ((the mouseH - sprite(1).left) * 2 / gVariable / 2) + 1, startY + 1)
  24.           else
  25.             if ((the mouseH - sprite(1).left) * 2 / gVariable / 2) = startX then
  26.               myShape = rect((the mouseH - sprite(1).left) * 2 / gVariable / 2, startY, startX + 1, ((the mouseV - sprite(1).top) * 2 / gVariable / 2) + 1)
  27.             else
  28.               myShape = rect(startX, startY, ((the mouseH - sprite(1).left) * 2 / gVariable / 2) + 1, ((the mouseV - sprite(1).top) * 2 / gVariable / 2) + 1)
  29.             end if
  30.           end if
  31.         end if
  32.       end if
  33.     end if
  34.     if (myShape.width = 0) or (myShape.height = 0) then
  35.       nothing()
  36.       next repeat
  37.     end if
  38.     firstIndex = gFirstColor.paletteIndex
  39.     secondIndex = gSecondColor.paletteIndex
  40.     myShapeWidth = myShape.width
  41.     colorSpread = abs(firstIndex - secondIndex) + 1
  42.     colorStep = colorSpread / float(myShapeWidth)
  43.     l = myShape.left
  44.     r = l + 1
  45.     c = firstIndex
  46.     repeat while myShapeWidth > 1
  47.       myCurrentImage.fill(rect(l, myShape.top, r, myShape.bottom), [#shapeType: #rect, #lineSize: 0, #color: paletteIndex(c)])
  48.       myShapeWidth = myShapeWidth - 1
  49.       colorSpread = secondIndex - c
  50.       colorStep = colorSpread / float(myShapeWidth)
  51.       l = r
  52.       r = l + 1
  53.       c = c + colorStep
  54.     end repeat
  55.     myCurrentImage.fill(rect(l, myShape.top, myShape.right, myShape.bottom), [#shapeType: #rect, #lineSize: 0, #color: paletteIndex(c)])
  56.     member(gSize & "x" & gSize, gCast).image.copyPixels(myCurrentImage, myCurrentImage.rect, myCurrentImage.rect)
  57.     updateStage()
  58.     put myShape.width.abs into field "dimension status W"
  59.     put myShape.height.abs into field "dimension status H"
  60.     fnUpdatePreview()
  61.   end repeat
  62.   sprite(35).pState = 0
  63.   sendSprite(35, #setMember)
  64.   member("state2 - " & gSize, gCast).image = member(gSize & "x" & gSize, gCast).image
  65.   myStartImage = VOID
  66.   myCurrentImage = VOID
  67.   myCurrentPreview = VOID
  68.   put EMPTY into field "dimension status W"
  69.   put EMPTY into field "dimension status H"
  70. end
  71.  
  72. on toolGradientV
  73.   member("state1 - " & gSize, gCast).image = member(gSize & "x" & gSize, gCast).image
  74.   startX = (the mouseH - sprite(1).left) * 2 / gVariable / 2
  75.   startY = (the mouseV - sprite(1).top) * 2 / gVariable / 2
  76.   myShape = rect(0, 0, 0, 0)
  77.   myStartImage = duplicate(member(gSize & "x" & gSize, gCast).image)
  78.   myCurrentImage = duplicate(member(gSize & "x" & gSize, gCast).image)
  79.   myCurrentPreview = duplicate(member("preview", gCast).image)
  80.   repeat while the mouseDown
  81.     myCurrentImage.copyPixels(myStartImage, myStartImage.rect, myStartImage.rect)
  82.     if (((the mouseV - sprite(1).top) * 2 / gVariable / 2) < startY) and (((the mouseH - sprite(1).left) * 2 / gVariable / 2) < startX) then
  83.       myShape = rect((the mouseH - sprite(1).left) * 2 / gVariable / 2, (the mouseV - sprite(1).top) * 2 / gVariable / 2, startX + 1, startY + 1)
  84.     else
  85.       if (((the mouseV - sprite(1).top) * 2 / gVariable / 2) < startY) and (((the mouseH - sprite(1).left) * 2 / gVariable / 2) >= startX) then
  86.         myShape = rect(startX, (the mouseV - sprite(1).top) * 2 / gVariable / 2, ((the mouseH - sprite(1).left) * 2 / gVariable / 2) + 1, startY + 1)
  87.       else
  88.         if (((the mouseV - sprite(1).top) * 2 / gVariable / 2) >= startY) and (((the mouseH - sprite(1).left) * 2 / gVariable / 2) < startX) then
  89.           myShape = rect((the mouseH - sprite(1).left) * 2 / gVariable / 2, startY, startX + 1, ((the mouseV - sprite(1).top) * 2 / gVariable / 2) + 1)
  90.         else
  91.           if ((the mouseV - sprite(1).top) * 2 / gVariable / 2) = startY then
  92.             myShape = rect(startX, (the mouseV - sprite(1).top) * 2 / gVariable / 2, ((the mouseH - sprite(1).left) * 2 / gVariable / 2) + 1, startY + 1)
  93.           else
  94.             if ((the mouseH - sprite(1).left) * 2 / gVariable / 2) = startX then
  95.               myShape = rect((the mouseH - sprite(1).left) * 2 / gVariable / 2, startY, startX + 1, ((the mouseV - sprite(1).top) * 2 / gVariable / 2) + 1)
  96.             else
  97.               myShape = rect(startX, startY, ((the mouseH - sprite(1).left) * 2 / gVariable / 2) + 1, ((the mouseV - sprite(1).top) * 2 / gVariable / 2) + 1)
  98.             end if
  99.           end if
  100.         end if
  101.       end if
  102.     end if
  103.     if (myShape.width = 0) or (myShape.height = 0) then
  104.       nothing()
  105.       next repeat
  106.     end if
  107.     firstIndex = gFirstColor.paletteIndex
  108.     secondIndex = gSecondColor.paletteIndex
  109.     myShapeHeight = myShape.height
  110.     colorSpread = abs(firstIndex - secondIndex) + 1
  111.     colorStep = colorSpread / float(myShapeHeight)
  112.     t = myShape.top
  113.     b = t + 1
  114.     c = firstIndex
  115.     repeat while myShapeHeight > 1
  116.       myCurrentImage.fill(rect(myShape.left, t, myShape.right, b), [#shapeType: #rect, #lineSize: 0, #color: paletteIndex(c)])
  117.       myShapeHeight = myShapeHeight - 1
  118.       colorSpread = secondIndex - c
  119.       colorStep = colorSpread / float(myShapeHeight)
  120.       t = b
  121.       b = t + 1
  122.       c = c + colorStep
  123.     end repeat
  124.     myCurrentImage.fill(rect(myShape.left, t, myShape.right, myShape.bottom), [#shapeType: #rect, #lineSize: 0, #color: paletteIndex(c)])
  125.     member(gSize & "x" & gSize, gCast).image.copyPixels(myCurrentImage, myCurrentImage.rect, myCurrentImage.rect)
  126.     updateStage()
  127.     put myShape.width.abs into field "dimension status W"
  128.     put myShape.height.abs into field "dimension status H"
  129.     fnUpdatePreview()
  130.   end repeat
  131.   sprite(35).pState = 0
  132.   sendSprite(35, #setMember)
  133.   member("state2 - " & gSize, gCast).image = member(gSize & "x" & gSize, gCast).image
  134.   myStartImage = VOID
  135.   myCurrentImage = VOID
  136.   myCurrentPreview = VOID
  137.   put EMPTY into field "dimension status W"
  138.   put EMPTY into field "dimension status H"
  139. end
  140.  
  141. on toolGradientOval
  142.   member("state1 - " & gSize, gCast).image = member(gSize & "x" & gSize, gCast).image
  143.   startX = (the mouseH - sprite(1).left) * 2 / gVariable / 2
  144.   startY = (the mouseV - sprite(1).top) * 2 / gVariable / 2
  145.   myShape = rect(0, 0, 0, 0)
  146.   myStartImage = duplicate(member(gSize & "x" & gSize, gCast).image)
  147.   myCurrentImage = duplicate(member(gSize & "x" & gSize, gCast).image)
  148.   myCurrentPreview = duplicate(member("preview", gCast).image)
  149.   repeat while the mouseDown
  150.     myCurrentImage.copyPixels(myStartImage, myStartImage.rect, myStartImage.rect)
  151.     if (((the mouseV - sprite(1).top) * 2 / gVariable / 2) < startY) and (((the mouseH - sprite(1).left) * 2 / gVariable / 2) < startX) then
  152.       myShape = rect((the mouseH - sprite(1).left) * 2 / gVariable / 2, (the mouseV - sprite(1).top) * 2 / gVariable / 2, startX + 1, startY + 1)
  153.     else
  154.       if (((the mouseV - sprite(1).top) * 2 / gVariable / 2) < startY) and (((the mouseH - sprite(1).left) * 2 / gVariable / 2) >= startX) then
  155.         myShape = rect(startX, (the mouseV - sprite(1).top) * 2 / gVariable / 2, ((the mouseH - sprite(1).left) * 2 / gVariable / 2) + 1, startY + 1)
  156.       else
  157.         if (((the mouseV - sprite(1).top) * 2 / gVariable / 2) >= startY) and (((the mouseH - sprite(1).left) * 2 / gVariable / 2) < startX) then
  158.           myShape = rect((the mouseH - sprite(1).left) * 2 / gVariable / 2, startY, startX + 1, ((the mouseV - sprite(1).top) * 2 / gVariable / 2) + 1)
  159.         else
  160.           if ((the mouseV - sprite(1).top) * 2 / gVariable / 2) = startY then
  161.             myShape = rect(startX, (the mouseV - sprite(1).top) * 2 / gVariable / 2, ((the mouseH - sprite(1).left) * 2 / gVariable / 2) + 1, startY + 1)
  162.           else
  163.             if ((the mouseH - sprite(1).left) * 2 / gVariable / 2) = startX then
  164.               myShape = rect((the mouseH - sprite(1).left) * 2 / gVariable / 2, startY, startX + 1, ((the mouseV - sprite(1).top) * 2 / gVariable / 2) + 1)
  165.             else
  166.               myShape = rect(startX, startY, ((the mouseH - sprite(1).left) * 2 / gVariable / 2) + 1, ((the mouseV - sprite(1).top) * 2 / gVariable / 2) + 1)
  167.             end if
  168.           end if
  169.         end if
  170.       end if
  171.     end if
  172.     if (myShape.height < 3) or (myShape.width < 3) then
  173.       myCurrentImage.fill(myShape, [#shapeType: #oval, #lineSize: 0, #color: gFirstColor])
  174.       next repeat
  175.     end if
  176.     myShapeHeight = myShape.height
  177.     myShapeWidth = myShape.width
  178.     firstIndex = gFirstColor.paletteIndex
  179.     secondIndex = gSecondColor.paletteIndex
  180.     colorSpread = abs(firstIndex - secondIndex) + 1
  181.     colorStep = ((colorSpread / float(myShape.height) * 2) + (colorSpread / float(myShape.width) * 2)) / 2
  182.     l = myShape.left
  183.     t = myShape.top
  184.     r = myShape.right
  185.     b = myShape.bottom
  186.     c = firstIndex
  187.     repeat while (myShapeHeight > 2) and (myShapeWidth > 2)
  188.       myCurrentImage.fill(rect(l, t, r, b), [#shapeType: #oval, #lineSize: 0, #color: paletteIndex(c)])
  189.       myShapeHeight = myShapeHeight - 2
  190.       myShapeWidth = myShapeWidth - 2
  191.       colorSpread = secondIndex - c
  192.       colorStep = ((colorSpread / float(myShapeHeight) * 2) + (colorSpread / float(myShapeWidth) * 2)) / 2
  193.       l = l + 1
  194.       t = t + 1
  195.       r = r - 1
  196.       b = b - 1
  197.       c = c + colorStep
  198.     end repeat
  199.     if (myShapeHeight = 1) and (myShapeWidth = 1) then
  200.       myCurrentImage.setPixel(l, t, gSecondColor)
  201.     else
  202.       myCurrentImage.fill(rect(l, t, r, b), [#shapeType: #oval, #lineSize: 0, #color: gSecondColor])
  203.     end if
  204.     member(gSize & "x" & gSize, gCast).image.copyPixels(myCurrentImage, myCurrentImage.rect, myCurrentImage.rect)
  205.     updateStage()
  206.     put myShape.width.abs into field "dimension status W"
  207.     put myShape.height.abs into field "dimension status H"
  208.     fnUpdatePreview()
  209.   end repeat
  210.   sprite(35).pState = 0
  211.   sendSprite(35, #setMember)
  212.   member("state2 - " & gSize, gCast).image = member(gSize & "x" & gSize, gCast).image
  213.   myStartImage = VOID
  214.   myCurrentImage = VOID
  215.   myCurrentPreview = VOID
  216.   put EMPTY into field "dimension status W"
  217.   put EMPTY into field "dimension status H"
  218. end
  219.  
  220. on toolGradientRect
  221.   member("state1 - " & gSize, gCast).image = member(gSize & "x" & gSize, gCast).image
  222.   startX = (the mouseH - sprite(1).left) * 2 / gVariable / 2
  223.   startY = (the mouseV - sprite(1).top) * 2 / gVariable / 2
  224.   myShape = rect(0, 0, 0, 0)
  225.   myStartImage = duplicate(member(gSize & "x" & gSize, gCast).image)
  226.   myCurrentImage = duplicate(member(gSize & "x" & gSize, gCast).image)
  227.   myCurrentPreview = duplicate(member("preview", gCast).image)
  228.   repeat while the mouseDown
  229.     myCurrentImage.copyPixels(myStartImage, myStartImage.rect, myStartImage.rect)
  230.     if (((the mouseV - sprite(1).top) * 2 / gVariable / 2) < startY) and (((the mouseH - sprite(1).left) * 2 / gVariable / 2) < startX) then
  231.       myShape = rect((the mouseH - sprite(1).left) * 2 / gVariable / 2, (the mouseV - sprite(1).top) * 2 / gVariable / 2, startX + 1, startY + 1)
  232.     else
  233.       if (((the mouseV - sprite(1).top) * 2 / gVariable / 2) < startY) and (((the mouseH - sprite(1).left) * 2 / gVariable / 2) >= startX) then
  234.         myShape = rect(startX, (the mouseV - sprite(1).top) * 2 / gVariable / 2, ((the mouseH - sprite(1).left) * 2 / gVariable / 2) + 1, startY + 1)
  235.       else
  236.         if (((the mouseV - sprite(1).top) * 2 / gVariable / 2) >= startY) and (((the mouseH - sprite(1).left) * 2 / gVariable / 2) < startX) then
  237.           myShape = rect((the mouseH - sprite(1).left) * 2 / gVariable / 2, startY, startX + 1, ((the mouseV - sprite(1).top) * 2 / gVariable / 2) + 1)
  238.         else
  239.           if ((the mouseV - sprite(1).top) * 2 / gVariable / 2) = startY then
  240.             myShape = rect(startX, (the mouseV - sprite(1).top) * 2 / gVariable / 2, ((the mouseH - sprite(1).left) * 2 / gVariable / 2) + 1, startY + 1)
  241.           else
  242.             if ((the mouseH - sprite(1).left) * 2 / gVariable / 2) = startX then
  243.               myShape = rect((the mouseH - sprite(1).left) * 2 / gVariable / 2, startY, startX + 1, ((the mouseV - sprite(1).top) * 2 / gVariable / 2) + 1)
  244.             else
  245.               myShape = rect(startX, startY, ((the mouseH - sprite(1).left) * 2 / gVariable / 2) + 1, ((the mouseV - sprite(1).top) * 2 / gVariable / 2) + 1)
  246.             end if
  247.           end if
  248.         end if
  249.       end if
  250.     end if
  251.     if (myShape.height < 3) or (myShape.width < 3) then
  252.       myCurrentImage.fill(myShape, [#shapeType: #rect, #lineSize: 0, #color: gFirstColor])
  253.       next repeat
  254.     end if
  255.     myShapeHeight = myShape.height
  256.     myShapeWidth = myShape.width
  257.     firstIndex = gFirstColor.paletteIndex
  258.     secondIndex = gSecondColor.paletteIndex
  259.     colorSpread = abs(firstIndex - secondIndex) + 1
  260.     colorStep = ((colorSpread / float(myShape.height) * 2) + (colorSpread / float(myShape.width) * 2)) / 2
  261.     l = myShape.left
  262.     t = myShape.top
  263.     r = myShape.right
  264.     b = myShape.bottom
  265.     c = firstIndex
  266.     repeat while (myShapeHeight > 2) and (myShapeWidth > 2)
  267.       myCurrentImage.fill(rect(l, t, r, b), [#shapeType: #rect, #lineSize: 0, #color: paletteIndex(c)])
  268.       myShapeHeight = myShapeHeight - 2
  269.       myShapeWidth = myShapeWidth - 2
  270.       colorSpread = secondIndex - c
  271.       colorStep = ((colorSpread / float(myShapeHeight) * 2) + (colorSpread / float(myShapeWidth) * 2)) / 2
  272.       l = l + 1
  273.       t = t + 1
  274.       r = r - 1
  275.       b = b - 1
  276.       c = c + colorStep
  277.     end repeat
  278.     if (myShapeHeight = 1) and (myShapeWidth = 1) then
  279.       myCurrentImage.setPixel(l, t, gSecondColor)
  280.     else
  281.       myCurrentImage.fill(rect(l, t, r, b), [#shapeType: #rect, #lineSize: 0, #color: gSecondColor])
  282.     end if
  283.     member(gSize & "x" & gSize, gCast).image.copyPixels(myCurrentImage, myCurrentImage.rect, myCurrentImage.rect)
  284.     updateStage()
  285.     put myShape.width.abs into field "dimension status W"
  286.     put myShape.height.abs into field "dimension status H"
  287.     fnUpdatePreview()
  288.   end repeat
  289.   sprite(35).pState = 0
  290.   sendSprite(35, #setMember)
  291.   member("state2 - " & gSize, gCast).image = member(gSize & "x" & gSize, gCast).image
  292.   myStartImage = VOID
  293.   myCurrentImage = VOID
  294.   myCurrentPreview = VOID
  295.   put EMPTY into field "dimension status W"
  296.   put EMPTY into field "dimension status H"
  297. end
  298.